home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1432.dms / var1432.adf / NDUK-V40.lha / V40 / include / exec / ables.i next >
Text File  |  1993-10-15  |  4KB  |  129 lines

  1.     IFND    EXEC_ABLES_I
  2. EXEC_ABLES_I    SET    1
  3. **
  4. **    $VER: ables.i 39.0 (15.10.91)
  5. **    Includes Release 40.15
  6. **
  7. **    Task switch and interrupt control macros
  8. **
  9. **    (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. **
  12.  
  13.     IFND EXEC_TYPES_I
  14.     INCLUDE "exec/types.i"
  15.     ENDC    ; EXEC_TYPES_I
  16.  
  17.     IFND EXEC_EXECBASE_I
  18.     INCLUDE "exec/execbase.i"
  19.     ENDC    ; EXEC_EXECBASE_I
  20.  
  21.  
  22. *-------------------------------------------------------------------------
  23. *
  24. *   Interrupt Exclusion Macros.  Disable all tasks and interrupts.
  25. *
  26. *-------------------------------------------------------------------------
  27.  
  28. INT_ABLES   MACRO        ; externals used by DISABLE and ENABLE
  29.         XREF    _intena
  30.         ENDM
  31.  
  32. ;Disable interrupts.  Avoid use of DISABLE if at all possible.
  33. ;Please realize the danger of this macro!  Don't disable for long periods!
  34. DISABLE     MACRO   ; [scratchReg],[NOFETCH] or have ExecBase in A6.
  35.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  36.           MOVE.W  #$04000,_intena    ;(NOT IF_SETCLR)+IF_INTEN
  37.           ADDQ.B  #1,IDNestCnt(A6)
  38.           MEXIT
  39.         ENDC
  40.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  41.           MOVE.W  #$04000,_intena
  42.           ADDQ.B  #1,IDNestCnt(\1)
  43.           MEXIT
  44.         ENDC
  45.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  46.           MOVE.L  4,\1        ;Get ExecBase
  47.           MOVE.W  #$04000,_intena
  48.           ADDQ.B  #1,IDNestCnt(\1)
  49.           MEXIT
  50.         ENDC
  51.         ENDM
  52.  
  53. ;Enable interrupts.  Please realize the danger of this macro!
  54. ENABLE        MACRO   ; [scratchReg],[NOFETCH] or have ExecBase in A6.
  55.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  56.           SUBQ.B  #1,IDNestCnt(A6)
  57.           BGE.S   ENABLE\@
  58.           MOVE.W  #$0C000,_intena    ;IF_SETCLR+IF_INTEN
  59. ENABLE\@:
  60.           MEXIT
  61.         ENDC
  62.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  63.           SUBQ.B  #1,IDNestCnt(\1)
  64.           BGE.S   ENABLE\@
  65.           MOVE.W  #$0C000,_intena
  66. ENABLE\@:
  67.           MEXIT
  68.         ENDC
  69.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  70.           MOVE.L  4,\1        ;Get ExecBase
  71.           SUBQ.B  #1,IDNestCnt(\1)
  72.           BGE.S   ENABLE\@
  73.           MOVE.W  #$0C000,_intena
  74. ENABLE\@:
  75.           MEXIT
  76.         ENDC
  77.         ENDM
  78.  
  79.  
  80. *-------------------------------------------------------------------------
  81. *
  82. *   Tasking Exclusion Macros.  Forbid all other tasks (but not interrupts)
  83. *
  84. *-------------------------------------------------------------------------
  85.  
  86. TASK_ABLES  MACRO        ; externals used by FORBID and PERMIT
  87.         XREF    _LVOPermit
  88.         ENDM
  89.  
  90. ;Prevent task switching (disables reschedule)
  91. FORBID        MACRO   ; [scratchReg],[NOFETCH] or ExecBase in A6!
  92.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  93.           ADDQ.B  #1,TDNestCnt(A6)
  94.           MEXIT
  95.         ENDC
  96.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  97.           ADDQ.B  #1,TDNestCnt(\1)
  98.           MEXIT
  99.         ENDC
  100.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  101.           MOVE.L  4,\1    ;Get ExecBase
  102.           ADDQ.B  #1,TDNestCnt(\1)
  103.           MEXIT
  104.         ENDC
  105.         ENDM
  106.  
  107. ;Enable task switching
  108. PERMIT        MACRO   ; [saveFlag],[NOFETCH] or ExecBase in A6!
  109.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  110.           JSR     _LVOPermit(A6)
  111.           MEXIT
  112.         ENDC
  113.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  114.           EXG.L   A6,\1        ;put execbase in A6
  115.           JSR     _LVOPermit(A6)    ;no registers touched.  A6=ExecBase
  116.           EXG.L   A6,\1
  117.           MEXIT
  118.         ENDC
  119.         IFNC    '\1',''             ;Case 2: save/restore A6
  120.           MOVE.L  A6,-(SP)
  121.           MOVE.L  4,A6
  122.           JSR     _LVOPermit(A6)
  123.           MOVE.L  (SP)+,A6
  124.           MEXIT
  125.         ENDC
  126.         ENDM
  127.  
  128.     ENDC    ; EXEC_ABLES_I
  129.